package com.wang.springbootinit.controller;

import com.wang.springbootinit.common.BaseResponse;
import com.wang.springbootinit.common.ResultUtils;
import com.wang.springbootinit.model.entity.Feedback;
import com.wang.springbootinit.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 学生端反馈控制器
 * 处理学生提交反馈相关的操作
 */
@RestController
@RequestMapping("/student/feedback")
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;

    /**
     * 提交反馈
     * @param feedback 反馈信息
     * @return 操作结果
     */
    @PostMapping("/submit")
    public BaseResponse submitFeedback(@RequestBody Feedback feedback,HttpServletRequest request) {
        return ResultUtils.success(feedbackService.submitFeedback(feedback,request));
    }

    /**
     * 获取我的反馈列表
     * @param request
     * @return 反馈列表
     */
    @GetMapping("/my")
    public BaseResponse getMyFeedbacks(HttpServletRequest request) {
        return ResultUtils.success(feedbackService.getMyFeedbacks(request));
    }

    /**
     * 获取反馈详情
     * @param feedbackId 反馈ID
     * @return 反馈详情
     */
    @GetMapping("/get/{id}")
    public BaseResponse getFeedbackById(@PathVariable("id") Long feedbackId) {
        return ResultUtils.success(feedbackService.getFeedbackById(feedbackId));
    }
} 